import time
from selenium import webdriver


# 打开浏览器,请求目标网址
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
driver.maximize_window()
time.sleep(2)
# 添加登录需要的cookie
cookies = [{
    'name':'BDUSS','value':'ljcWJ6aEFCYXJyTjZFNG8zVWRYVUxVNTJGOX5ISjFXYmVCMTV0Nm04c2duS2xpRVFBQUFBJCQAAAAAAAAAAAEAAAAMZbQwsbO-sMjLzu-xsc~-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAPgmIgD4JiTD'
},{
    'name':'BDUSS_BFESS','value':'ljcWJ6aEFCYXJyTjZFNG8zVWRYVUxVNTJGOX5ISjFXYmVCMTV0Nm04c2duS2xpRVFBQUFBJCQAAAAAAAAAAAEAAAAMZbQwsbO-sMjLzu-xsc~-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAPgmIgD4JiTD'
}]
# 添加cookie
driver.add_cookie(cookies[0])
driver.add_cookie(cookies[1])
# 刷新浏览器
driver.refresh()

# 退出浏览器
time.sleep(5)
driver.quit()